import { Component, OnInit, ViewChild } from '@angular/core';
import { _HttpClient } from '@delon/theme';
import { STComponent, STData } from '@delon/abc';
import { SPage } from '@shared/components/table-page/table-page.component';
import { NzModalService } from 'ng-zorro-antd';
import { ApiService } from '@core/services/api';
import { PeopleDetailComponent } from '../../person-info/people-detail/people-detail.component';

@Component({
  selector: 'app-manage-list',
  templateUrl: './manage-list.component.html',
})
export class ManageListComponent implements OnInit {
  @ViewChild('st', { static: false }) st: STComponent;
  isVisible = false;
  config: SPage = {
    columns: [
      /*{
        index: 'id',
        title: '多选',
        type: ColumnType.checkbox,
      },*/
      {
        index: 'managerName',
        title: '姓名',
        filter: {
          placeholder: '',
          type: 'string',
        },
      },
      {
        index: 'houseCode',
        title: '房号',
        filter: {
          placeholder: '请输房号',
          type: 'string',
        },
      },
      {
        index: 'infoMobile',
        title: '手机号码',
        /*filter: {
          placeholder: '请输入手机号',
          type: 'string',
        },*/
      },
      {
        index: 'infoIdcardNumber',
        title: '证件号码',
        filter: {
          placeholder: '请输入证件号码',
          type: 'string',
        },
      },
      {
        index: 'infoNativeAddress',
        title: '户籍所在地',
        /*filter: {
          placeholder: '请输入户籍所在地',
          type: 'string',
        },*/
      },
      {
        index: 'type',
        title: '管理员类型',
        filter: {
          placeholder: '请选择管理员类型',
          type: 'select',
          items: [
            { label: '业主', value: '1' },
            { label: '综管员', value: '2' },
            { label: '房屋管理员', value: '3' },
            { label: '运维人员', value: '4' },
            { label: '清洁人员', value: '5' },
          ],
        },
      },
    ],
    showCheckBox: true,
    editBtn: [
      { title: '查看详情' },
    ],
    reqUrl: this.api.peopleInfo.managerPage.url,
  };

  constructor(private http: _HttpClient, private modal: NzModalService, private api: ApiService) {
  }

  ngOnInit() {
  }

// 根据状态检索不需要被全选的数据
  dataProcess() {
    return this.config.data.map((i: STData, index: number) => {
      return i;
    });
  }

// 操作区
  operate(e): void {
    switch (e.title) {
      case '查看详情':
        this.previewDital(e.data);
        break;
    }
  }

// 选择数据
  selectChange(e) {
    console.log(e);

  }

  /**
   * 查看详情
   * @param _param 人员详情
   */
  previewDital(_param): void {
    this.modal.create({
      nzTitle: '人员详情',
      nzWidth: 1000,
      nzContent: PeopleDetailComponent,
      nzComponentParams: {
        _param,
      },
      nzFooter: null,
    });
  }
}
